package j.quartz.frame.core.common.entity;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

/**
 * 抽象实体基类
 */

@SuppressWarnings("serial")
public abstract class AbstractEntity extends BaseEntity {

	public abstract String getUuid();

	public abstract void setUuid(String uuid);
	 
	public boolean isNew() {

		return null == getUuid();
	}

	@Override
	public boolean equals(Object obj) {

		if (null == obj) {
			return false;
		}

		if (this == obj) {
			return true;
		}

		if (!getClass().equals(obj.getClass())) {
			return false;
		}

		AbstractEntity that = (AbstractEntity) obj;

		return null == this.getUuid() ? false : this.getUuid().equals(that.getUuid());
	}

	@Override
	public int hashCode() {

		int hashCode = 17;

		hashCode += null == getUuid() ? 0 : getUuid().hashCode() * 31;

		return hashCode;
	}

	@Override
	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}
}
